package com.zjm.structural.proxy.demo02_dynamic;

public class Client {
    public static void main(String[] args) {
        // 创建目标对象
        ITeacherDao target = new TeacherDao();
        // 给目标对象创建代理对象
        ITeacherDao proxyInstance = (ITeacherDao) new ProxyFactory(target).getProxyInstance();

        // proxyInstance:class jdk.proxy1.$Proxy0 内存中动态生成了代理对象
        System.out.println("proxyInstance:"+proxyInstance.getClass());

        // 通过代理的对象调用目标对象的方法
        proxyInstance.teach();

        proxyInstance.sayHello("tom");
    }
}
